<!--
 * @Descripttion: 
 * @Author: YuZhenJing
 * @Date: 2020-01-21 09:07:22
 * @LastEditors: YuZhenJing
 * @LastEditTime: 2020-05-14 08:51:34
 -->
<template>
  <div class="sys-caching">
    <div style="height:calc(100vh - 149px)">
      <div style="width:800px;margin:0px auto;">
        <el-card class="box-card">
          <div slot="header" style="text-align:center">
            <el-button-group>
              <el-button
                :loading="saveLoading"
                icon="el-icon-refresh"
                type="primary"
                @click="refreshMenu"
                >刷新功能清单</el-button
              >
              <el-button
                :loading="saveLoading"
                icon="el-icon-refresh"
                type="primary"
                @click="refreshOrg"
                >刷新组织机构</el-button
              >
              <el-button
                :loading="saveLoading"
                icon="el-icon-refresh"
                type="primary"
                @click="refreshAuthApi"
                >刷新API授权</el-button
              >
            </el-button-group>
          </div>
          <div style="height:400px">
            <div class="msg-box" :class="{ show: resultMsg != '' }">
              <span v-text="resultMsg"></span>
            </div>
          </div>
        </el-card>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      saveLoading: false,
      resultMsg: ''
    }
  },
  methods: {
    refreshMenu() {
      this.saveLoading = true
      this.resultMsg = ''
      const options = this.$html.get('help/setting/refreshMenu')
      options
        .then(data => {
          if (data.returnType == 'success') {
            this.resultMsg = data.returnData
            this.saveLoading = false
          }
        })
        .catch(() => {
          this.saveLoading = false
          console.log('error:sysCaching/refreshMenu')
        })
    },
    refreshOrg() {
      this.saveLoading = true
      this.resultMsg = ''
      const options = this.$html.get('help/setting/refreshOrg')
      options
        .then(data => {
          if (data.returnType == 'success') {
            this.resultMsg = data.returnData
            this.saveLoading = false
          }
        })
        .catch(() => {
          this.saveLoading = false
          console.log('error:sysCaching/refreshOrg')
        })
    },
    refreshAuthApi() {
      this.saveLoading = true
      this.resultMsg = ''
      const options = this.$html.get(
        this.bodyRootUrl.asmCore + 'help/setting/refreshAuthApi',
        null,
        {
          root: true
        }
      )
      options
        .then(data => {
          if (data.returnType == 'success') {
            this.resultMsg = data.returnData
            this.saveLoading = false
          }
        })
        .catch(() => {
          this.saveLoading = false
          console.log('error:sysCaching/refreshAuthApi')
        })
    }
  }
}
</script>
<style lang="stylus" scope>
.msg-box
  transform  translateX(-100px)
  transition 0.5s
  opacity 0
  &.show
    transform translateX(0px)
    opacity 1
</style>
